import asyncio
import time

from utils.handler import AsyncHandler
from utils.log import Log


class MyClass(Log):
    @AsyncHandler()
    async def f(self):
        await asyncio.sleep(3)
        # time.sleep(3)
        self.info('f done')
        return 42

    @AsyncHandler(end=True)
    async def g(self):
        self.info('g done')
        return 1 / 0
        # self.error(33, "test error")


async def main():
    my_class = MyClass()
    return await asyncio.gather(my_class.f(), my_class.f(),
                                my_class.f(), my_class.f(),
                                my_class.g())


if __name__ == '__main__':
    asyncio.run(main())
